package com.lenovo.dh.voteclient.utils;

import com.lenovo.dh.voteclient.R;

import android.content.Context;
import android.content.SharedPreferences;
import android.telephony.TelephonyManager;

public class Utils {
	public static void saveNameByShare(Context mContext,String name) {
		SharedPreferences userInfo = mContext.getSharedPreferences("user_info", 0);
		userInfo.edit().putString("name", name).commit();
	}
	public static String getNameByShare(Context mContext) {
		SharedPreferences userInfo = mContext.getSharedPreferences("user_info", 0);
		return userInfo.getString("name", "");
//		return "";
//		return mContext.getResources().getString(R.string.spe_name);
	}
	public static String getIME(Context mContext) {
		return ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
	}
	public static int px2dip(Context context, float pxValue){
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int)(pxValue / scale + 0.5f);
} 
	
	public static int dip2px(Context context, float dipValue){
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int)(dipValue * scale + 0.5f);
} 
}
